<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>

<c-rt:set var="returnIds" value="${pu:split(param.returnFieldIds, ',')}"/>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 10, 10)}"/>
<c-rt:if test="${empty param.keyword}">
	<c-rt:set var="members" value="${pu:queryByHql('from Member', null, tp)}"/>
</c-rt:if>
<c-rt:if test="${!empty param.keyword}">
	<c-rt:set var="hql">
	from Member where name like ? order by createDate desc
	</c-rt:set>
	<c-rt:set var="keyword">
	%${param.keyword }%
	</c-rt:set>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="members" value="${pu:queryByHql(hql, params, tp)}"/>
</c-rt:if>

<form name="memberSearchForm">
<input type="hidden" name="returnFieldIds" value="${param.returnFieldIds }"/>
<table>
<tr>
<td>关键字:<input type="text" value="${param.keyword }" name="keyword"/></td><td><div class="f-link"><a href="javascript:;" id="memberSelect">search</a></div></td>
</tr>
</table>
</form>
<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th>会员姓名</th>

			</tr>
		</thead>
		<tbody>
			<c-rt:forEach items="${members}" var="member" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td><a href="javascript:;" onclick="returnButton('${member.memberId}', '${member.name }')">${member.name }</a></td>
				</tr>
			</c-rt:forEach>
		</tbody>
	</table>
<c-rt:set var="url">
<%=application.getContextPath() %>/supplierApply/page.do
</c-rt:set>
<pageable:Pageable url="${url}" escapeparams="iamlazy,AJAX,refreshZone" parameter="iamlazy=memberList&AJAX=true&refreshZone=dialog" formname="memberForm" key="tpp"></pageable:Pageable>
<script>
$(document).ready(function(){
	$('#memberSelect').click(function(){
		doAR('<%=application.getContextPath() %>/cs/page.do?iamlazy=memberList&AJAX=true&refreshZone=dialog', 'dialog', 'memberSearchForm');
	});

});
function returnButton(memberId, memberName){
		<c-rt:forEach items="${returnIds}" var="returnId" varStatus="index">
		<c-rt:if test="${index.index==0}">
		$('#${returnId }').attr('value',memberId);
		</c-rt:if>
		<c-rt:if test="${index.index==1}">
		$('#${returnId }').attr('value',memberName);
		</c-rt:if>
		</c-rt:forEach>
		closeDialog();
}
</script>